use strict;
use warnings;
use Data::Dumper;
use HTTP::Cookies;
use SOAP::Lite;# on_debug => sub{print@_};
use Bio::Tools::Mgip;
use Test::More;

my($response,$mgip,$numTests,$organismId,$i,$j,$bool);
my($value,@value,%value); # for results
$numTests=0;

# dummy test
oka(1,"Starting the tests.\n");

$mgip=Bio::Tools::Mgip->new();

%value=$mgip->login(-username=>"demo",-password=>"demo");
oka($value{'id'} eq '1',"Log In");

%value=$mgip->getInfo();
oka($value{'id'} eq '1',"Cookies and sessioning");

# get the organism id
@value=$mgip->getOrganisms;
$value=${ %{$value[0]} }{genus};
$organismId=${ %{$value[0]} }{id};
oka($value eq 'Neisseria',"GetOrganisms, seeing if Neisseria is there.");

# switch to that organism
$value=$mgip->changeCurrentOrganism($organismId);
oka($value eq 1,"Changing organism");

# get the organism Loci.  abcZ should be one of the loci.
%value=$mgip->getLoci(0);
$bool=0;
foreach $value (%value){
	$bool=1 if($value eq 'abcZ');
}
oka($bool,"Get Loci");

plan tests=>$numTests;
done_testing;

# run the ok method and increment number of expected tests
sub oka{
  my($bool,$testName)=@_;
  $numTests++;
  ok($bool,$testName);
}

